package com.atguigu.mybatis.mapper;


import com.atguigu.mybatis.bean.Employee;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Mybatis的优点：
 *          sql和java源代码分离：
 *              sql:xxx.xml文件中mapper
 *              java代码：xxx.java中
 *              好处：如果sql需要经常维护，升级，降低运维成本
 *
 *  有些公司为了敏捷开发，一些不经常更新的sql，也会直接写在java代码中，看公司的规范和风格
 */
public interface EmployeeMapper2 {
    @Select(" select * from employee where id = #{hfiogfhaweoi;hgawo;il}")
    Employee getEmployeeById(Integer id);

    @Insert("insert into employee(last_name,gender,email) values(#{lastName},#{gender},#{email})")
    Employee insertEmployee(Employee employee);

    @Update("        update employee\n" +
            "        set last_name = #{lastName},email=#{email},gender=#{gender}\n" +
            "        where id = #{id}")
    Employee updateEmployee(Employee employee);

    @Delete("delete  from employee where id = #{id}")
    Employee deleteEmployeeById(Integer id);

    //查询所有员工
    @Select("delete  from employee where id = #{id}")
    List<Employee> getAll();
}


//public interface EmployeeMapper2Test {
//    @Select(" select * from employee where id = #{hfiogfhaweoi;hgawo;il}")
//    Employee getEmployeeById(Integer id);
//
//    @Insert("insert into employee(last_name,gender,email) values(#{lastName},#{gender},#{email})")
//    Employee insertEmployee(String id);
//
//    @Update("  update employee\n" +
//            "        set last_name = #{lastName},email=#{email},gender=#{gender}\n" +
//            "        where id = #{id}")
//    Employee updateEmployee(String id);
//
//    @Delete("delete  from employee where id = #{id}")
//    Employee deleteEmployeeById(Integer id);
//
//    @Select("select * from employee")
//    List<Employee> getAll();
//}

//public interface EmployeeMapper2 {
//    @Select("select * from employee where id = #{hfiogfhaweoi;hgawo;il}")
//    Employee getEmployeeById(Integer id);
//
//    @Insert("insert into employee(last_name,gender,email) values(#{lastName},#{gender},#{email})")
//    Employee insertEmployee(String id);
//
//    @Update(" update employee\n" +
//            "        set last_name = #{lastName},email=#{email},gender=#{gender}\n" +
//            "        where id = #{id}")
//    Employee updateEmployee(String id);
//
//    @Delete("delete  from employee where id = #{id}")
//    Employee deleteEmployeeById(Integer id);
//
//    @Select("select * from employee")
//    List<Employee> getAll();
//}